<html>
<head><meta charset="utf-8"><title>Setting lint levels on struct expr fields · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Setting.20lint.20levels.20on.20struct.20expr.20fields.html">Setting lint levels on struct expr fields</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="187979281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Setting%20lint%20levels%20on%20struct%20expr%20fields/near/187979281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andy Russell <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Setting.20lint.20levels.20on.20struct.20expr.20fields.html#187979281">(Feb 12 2020 at 03:42)</a>:</h4>
<p>Hi All, I'm trying to tackle <a href="https://github.com/rust-lang/rust/issues/60681" target="_blank" title="https://github.com/rust-lang/rust/issues/60681">https://github.com/rust-lang/rust/issues/60681</a>. I've tracked down the issue to a combination of the fact that struct expr attributes aren't stored in the lint level map, and the <a href="https://github.com/rust-lang/rust/blob/95e0a2c50d063bd7eb79aa55d16cd5fee715c280/src/librustc_typeck/check/expr.rs#L1215" target="_blank" title="https://github.com/rust-lang/rust/blob/95e0a2c50d063bd7eb79aa55d16cd5fee715c280/src/librustc_typeck/check/expr.rs#L1215">stability of a struct field attribute is checked by looking at the HIR ID of the whole expression</a>, not the field.</p>
<p>It's easy enough to fix the lint level map issue. I added a <code>visit_field</code> method to <code>intravisit::Visitor</code> and then used that in the <code>lint_levels</code> query. However, changing the stability check is harder: I run into a <a href="https://github.com/rust-lang/rust/blob/95e0a2c50d063bd7eb79aa55d16cd5fee715c280/src/librustc/ty/context.rs#L2586" target="_blank" title="https://github.com/rust-lang/rust/blob/95e0a2c50d063bd7eb79aa55d16cd5fee715c280/src/librustc/ty/context.rs#L2586"><code>bug!()</code></a> because the HIR ID of the field has no parent.</p>
<p>I'm wondering what to do next. I could try to give the field a parent in the HIR map, but this is a significant change because it would involve adding a new HIR node. Is there a better solution?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>